//
//  UIButton+Extensions.swift
//  weibo
//
//  Created by apple on 2017/5/18.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

import UIKit

extension UIButton {
    // convenience : 便利，使用convenience修饰的构造函数叫做便利构造函数
    // 遍历构造函数通常用在对系统的类进行构造函数的扩充时使用
    /*
     遍历构造函数的特点
     1.遍历构造函数通常都是写在extension里面
     2.遍历构造函数init前面需要加载convenience
     3.在遍历构造函数中需要明确的调用self.init()
     */
    convenience init(imageName:String , backImageName:String){
       self.init()
        setImage(UIImage(named: imageName), for: UIControlState.normal)
        setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        //setBackgroundImage(UIImage(named: backImageName), for: .Normal)
        //setBackgroundImage(UIImage(named: backImageName + "_highlighted"), for: .Highlighted)
        setBackgroundImage(UIImage(named: backImageName), for: UIControlState.normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), for: .highlighted)
        sizeToFit()
    }
    convenience init(title:String,fontSize:Float,normalColor:UIColor,highlightedColor: UIColor){
        self.init()
        setTitle(title, for: .normal)
        setTitleColor(normalColor, for: .normal)
        setTitleColor(highlightedColor, for: .highlighted)
        //setAttributedTitle([NSFontAttributeName:UIFont.systemFont(ofSize: 14)], for: UIControlState.normal)
       // setAttributedTitle(<#T##title: NSAttributedString?##NSAttributedString?#>, for: <#T##UIControlState#>)
        sizeToFit()
    }
}
